<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>PID</title>
  <link rel="stylesheet" href="__STATIC__/index/css/quan_common.css">
  <link rel="stylesheet" href="__STATIC__/index/css/single.css">
  <link rel="stylesheet" href="__STATIC__/index/css/common.css">
  <link rel="stylesheet" href="__STATIC__/index/css/uc_common.css">
  <link rel="stylesheet" href="__STATIC__/index/css/center2.css">
  <link rel="stylesheet" href="__STATIC__/index/css/all.css">
  <script src="__STATIC__/index/js/jquery-3.2.1.js"></script>
  <script src="__STATIC__/layer/layer.js"></script>
  <script src="__STATIC__/layui/layui.js"></script>
  <style>
    .pub-header .head-block .yrz .user-block .username i{
    top: 31px;
  }
    .PIDitem{
      	color: #4c6cc9 !important;
		    border-color: #4c6cc9 !important;
		    background-color: #e3efff;
      }
  </style>
</head>

 <!-- <script type="text/javascript">
  	function editPid(){
  		
  	}
  </script>-->


<body>
{include file='common/heade'}
   <div class="single_center w_1200">
  {include file='common/left_tg'}
<div class="ext-right">
	
  <div class="right-index border-all bg-white" style="width:1000px;">
    <div class="header-menu-item"><span id="iframeC" class="title">PID管理</span></div>
    <div class="pid-box">
      <p class="describe">
        <span>使用不同的推广方式建议使用不同的PID
          <a href="{:url('index/market/pidillustrate')}" class="" target="_blank">如何获取PID?</a>
        </span>
        <span style="float: right; padding-right: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <span style="color: rgb(76, 108, 201);"></span>&nbsp;有效期预计还剩:&nbsp;
          <span style="color: rgb(76, 108, 201);">{$num}</span>
        </span>
      </p>
      <p class="describe2" style="color: rgb(255, 102, 0);">
        <span> 一个联盟账号只能授权一个平台账号，2次授权会导致授权失败无法获取推广数据</span>
        <span style="float: right; padding-right: 120px;">请勿频繁授权，一个星期授权一次
        </span>
      </p>
      <div class="pid-btn-box">
        <div>
        	{if condition="$arr.session_key==''"}
          <div type="button" class="ysq-input ivu-btn ivu-btn-info">
            <span ><a href="#" onclick="session_sq()" style="color: #fff;">请授权</a></span>
          </div>
          {elseif condition="$arr.up_session_time < $arr.time"}
          <div class="ysq-input ivu-btn ivu-btn-info">
            <span ><a href="#" onclick="session_sq()" style="color: #fff;">请重新授权</a></span>
          </div>
          {/if}
           </div>
        </div>
    
      <div class="goods-table pid-table ivu-table-wrapper" style="height: 270px;">
        <div class="ivu-table ivu-table-with-fixed-top">
          <div class="ivu-table-header">
            <table cellspacing="0" cellpadding="0" style="width: 967px;">
              <colgroup>
                <col width="330">
                <col width="320">
                <col width="150">
                <col width="166">
              </colgroup>
              <thead>
                <tr>
                  <th class="">
                    <div class="ivu-table-cell"><span class="">PID用途</span>
                    </div>
                  </th>
                  <th class="">
                    <div class="ivu-table-cell"><span class="">选用PID</span>
                    </div>
                  </th>
                  <th class="">
                    <div class="ivu-table-cell"><span class="">配置状态</span>
                    </div>
                  </th>
                  <th class="">
                    <div class="ivu-table-cell"><span class="">操作</span>
                    </div>
                  </th>
                </tr>
              </thead>
            </table>
          </div>
          <div class="ivu-table-body" style="height: 229px;">
            <table cellspacing="0" cellpadding="0" style="width: 967px;">
              <colgroup>
                <col width="330">
                <col width="320">
                <col width="150">
                <col width="166">
              </colgroup>
              <tbody class="ivu-table-tbody">
                <tr class="ivu-table-row">
                  <td class="">
                    <div class="ivu-table-cell">
                      <div class="color666">
                        <p><b>转淘口令</b></p>
                        <p>转短链接</p>
                      </div>
                    </div>
                  </td>
                  <td style="padding:0">
                    <div class="ivu-table-cell">
                       <span id="">
                       	{$pid}
                       </span>
                  </td>
                  {if $pid}
                  <td class="">
                    <div class="ivu-table-cell">
                      <div class="ivu-tag ivu-tag-green ivu-tag-border ivu-tag-checked">
                        <span class="ivu-tag-text ivu-tag-color-green">正在使用</span>
                      </div>
                    </div>
                  </td>
                  <td class="">
                    <div class="ivu-table-cell change_btn">
                      <button type="button" class="ivu-btn ivu-btn-text ivu-btn-small blue"  onclick="editPid()">
                        <span>修改PID</span>
                      </button>
                      <button type="button" class="ivu-btn ivu-btn-text ivu-btn-small blue"  onclick="insertPid()">
                        <span>添加PID</span>
                      </button>
                    </div>
                  </td>
                  {else}
                  <td class="">
                    <div class="ivu-table-cell">
                      <div class="ivu-tag ivu-tag-green ivu-tag-border ivu-tag-checked">
                        <span class="ivu-tag-text ivu-tag-color-green">未使用</span>
                      </div>
                    </div>
                  </td>
                  <td class="">
                    <div class="ivu-table-cell change_btn">
                      <button type="button" class="ivu-btn ivu-btn-text ivu-btn-small blue"  onclick="insertPid()">
                        <span>添加PID</span>
                      </button>
                    </div>
                  </td>
                  {/if}
                </tr>
              </tbody>
            </table>
          </div>
         
        </div>
      </div>
    </div>
    
    <div class="pid-box">
      <div class="goods-table pid-table ivu-table-wrapper" style="height: 270px;">
        <div class="ivu-table ivu-table-with-fixed-top">
          <div class="ivu-table-header">
            <table cellspacing="0" cellpadding="0" style="width: 967px;">
              <colgroup>
                <col width="330">
                <col width="320">
                <col width="150">
                <col width="166">
              </colgroup>
              <thead>
                <tr>
                  <th class="">
                    <div class="ivu-table-cell"><span class="">绑定SESSION</span>
                    </div>
                  </th>
                  <th class="">
                    <div class="ivu-table-cell"><span class="">选用SESSION</span>
                    </div>
                  </th>
                  <th class="">
                    <div class="ivu-table-cell"><span class="">配置状态</span>
                    </div>
                  </th>
                  <th class="">
                    <div class="ivu-table-cell"><span class="">操作</span>
                    </div>
                  </th>
                </tr>
              </thead>
            </table>
          </div>
          <div class="ivu-table-body" style="height: 229px;">
            <table cellspacing="0" cellpadding="0" style="width: 967px;">
              <colgroup>
                <col width="330">
                <col width="320">
                <col width="150">
                <col width="166">
              </colgroup>
              <tbody class="ivu-table-tbody">
              	{if $arr.session_key==''}
                <tr class="ivu-table-row">
                  <td class="">
                    <div class="ivu-table-cell">
                      <div class="color666">
                        <p><b>转淘口令</b></p>
                        <p>转短链接</p>
                      </div>
                    </div>
                  </td>
                  <td class="">
                    <div class="ivu-table-cell">
                      <input type="" name="" id="session_key" value="" placeholder="请务必输入正确session值" style="width:100%;border: 1px solid #eee;;"/>
                    </div>
                  </td>
                  <td class="">
                    <div class="ivu-table-cell">
                      <div class="ivu-tag ivu-tag-green ivu-tag-border ivu-tag-checked">
                        <span class="ivu-tag-text ivu-tag-color-green">未配置</span>
                      </div>
                    </div>
                  </td>
                  <td class="">
                    <div class="ivu-table-cell change_btn">
                      <div type="button" class="ivu-btn ivu-btn-text ivu-btn-small blue" onclick="sureSession()">
                        <span >确定</span>
                      </div>
                    </div>
                  </td>
                </tr>
                {else}
                 <tr class="ivu-table-row">
                  <td class="">
                    <div class="ivu-table-cell">
                      <div class="color666">
                        <p><b>转淘口令</b></p>
                        <p>转短链接</p>
                      </div>
                    </div>
                  </td>
                  <td class="">
                    <div class="ivu-table-cell">
                      <input type="" name="" id="session_out" value="{$arr.session_key}" disabled="disabled" style="border: 1px solid #eee;width: 100%;"/>
                    </div>
                  </td>
                  	{if $arr.up_session_time < $arr.time}
                  <td class="">
                    <div class="ivu-table-cell">
                      <div class="ivu-tag ivu-tag-green ivu-tag-border ivu-tag-checked">
                        <span class="ivu-tag-text ivu-tag-color-green">session过期</span>
                      </div>
                    </div>
                  </td>
                  <td class="">
                    <div class="ivu-table-cell change_btn">
                         <span id="cancel"><a href="#" onclick="session_sq()">请重新授权</a></span>
                         <span id="confirm" style="color:#57a3f3; display:none;" onclick="sureSession_new()">
                         	确定
                         </span>
                    </div>
                  </td>
                  {else}
		                    <td class="">
		                    <div class="ivu-table-cell">
		                      <div class="ivu-tag ivu-tag-green ivu-tag-border ivu-tag-checked">
		                        <span class="ivu-tag-text ivu-tag-color-green">正在使用</span>
		                      </div>
		                    </div>
		                  </td>
		                  <td class="">
		                    <div class="ivu-table-cell change_btn">
		                        <span>正常</span>
		                    </div>
		                  </td>
                  {/if}
                </tr>
                {/if}
              </tbody>
            </table>
          </div>
         
        </div>
      </div>
    </div>
  </div>
  </div>
  </div>
 </div>
   <!--嵌入-->
  <!-- 添加子pid -->
</body>
<script type = "text/javascript">
   function sureSession(){
   	 var sessiontext = $('#session_key').val();
   	 //console.log(sessiontext)
   	 if(sessiontext==''){
   	 		layui.use('layer', function(){
				  var layer = layui.layer;
				  layer.alert('请输入session', {icon: 2});
					});              
			 		return false;
   	 }
   
   	$.ajax({
   		type:"post",
   		url:"{:url('market/sureSession')}",
   		data:{session_key:sessiontext},
   		success:function(res){
   			if(res.code==1){
   				layui.use('layer', function(){
				  var layer = layui.layer;
				  layer.alert(res.msg, {icon: 1},function(){
				  	location.reload(); 
				  });
					});              
			 		return false;
   			}else if(res.code==0){
   				layui.use('layer', function(){
				  var layer = layui.layer;
				  layer.alert(res.msg, {icon: 2});
					});              
			 		return false;
   			}
   		}
   	});
   	
   }
   
   function sureSession_new(){
   	var sessiontext = $('#session_out').val();
   	 //console.log(sessiontext)
   	 if(sessiontext==''){
   	 		layui.use('layer', function(){
				  var layer = layui.layer;
				  layer.alert('请输入session', {icon: 2});
					});              
			 		return false;
			 	}
   	 
			$.ajax({
   		type:"post",
   		url:"{:url('market/sureSession')}",
   		data:{session_key:sessiontext},
   		success:function(res){
   			if(res.code==1){
   				layui.use('layer', function(){
				  var layer = layui.layer;
				  layer.alert(res.msg, {icon: 1},function(){
				  	location.reload(); 
				  });
					});              
			 		return false;
   			}else if(res.code==0){
   				layui.use('layer', function(){
				  var layer = layui.layer;
				  layer.alert(res.msg, {icon: 2});
					});              
			 		return false;
   			}
   		}
   	});		
			 		
   }
   
   
   //session 授权
   function session_sq(){
	window.open("{:url('market/iframe_page')}");
	$("#session_out").attr("disabled",false);
	$("#session_out").val("");
	$('#confirm').css('display','block');
	$('#cancel').css('display','none');
   }
   
   
   
</script>

<script type = "text/javascript" >
 /* function check(){
    var v=document.getElementById("PIDcode").value;
    console.log(v);
  }*/

function editPid() {
        layer.open({
            type: 2,
            title: '修改pid',
            shadeClose: true,
            shade: 0.8,
            area: ['500px', '30%'],
            content: '{:url("editPid")}' //iframe的url
        });
    }

function insertPid() {
        layer.open({
            type: 2,
            title: '添加pid',
            shadeClose: true,
            shade: 0.8,
            area: ['500px', '30%'],
            content: '{:url("insertpid")}' //iframe的url
        });
    }

function getChild() {
        window.location.reload()
    }

</script>

</html>